
    Structure Person
        Public ID As Integer
        Public MonthlySalary As Decimal
        <VBFixedString(8)> Public Name As String
    End Structure
    Public Employee As Person
    Public Position As Long = 0      		 ¼λñ
дļ
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim RecLength As Long
        Position += 1
        RecLength = Len(Employee.MonthlySalary)
        RecLength = Len(Employee)
        FileOpen(1, "MYFILE.DAT", 4, , , RecLength)
        Employee.ID = Val(TextBox1.Text)
        Employee.Name = TextBox2.Text
        Employee.MonthlySalary = Val(TextBox3.Text)
        FilePut(1, Employee, Position)
        FileClose(1)
End Sub
ļ
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim FileNum As Integer, i, sum, RecLength As Long
        RecLength = Len(Employee)
        FileNum = FreeFile()
        FileOpen(FileNum, "MYFILE.DAT", OpenMode.Random, , , RecLength)
        sum = LOF(FileNum) / RecLength
        For i = 1 To sum
            FileGet(FileNum, Employee, i)
            Label4.Text &= Employee.ID & Employee.Name & Employee.MonthlySalary & Chr(10)
        Next
        FileClose(FileNum)
    End Sub
